define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        //餐饮生活类型列表
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'commission/commission/index',
                    add_url: 'commission/commission/add',
                    edit_url: 'commission/commission/edit',
                    del_url: 'commission/commission/del',
                    table: 'amoy',
                }
            });

            var table = $("#table");
            // 标题  封面图片 内容 文章来源
            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'amoy_id',
                sortName: 'amoy_id',
                columns: [
                    [
                        {field: 'amoy_id', title:'ID', operate: false},
                        {field: 'title', title: '标题', operate: false},
                        {field: 'cover', title: '封面图片', operate: false,formatter: Table.api.formatter.image},
                        {field: 'auto_content', title: '内容', operate: false},
                        {field: 'word_source', title: '文章来源', operate: false},
                        {field: 'add_time', title: '添加时间', operate: false, formatter: Table.api.formatter.date},
                        {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
                    ]
                ],
                showToggle: false,
                showColumns: false,
                search:false,
                showExport: false,
                commonSearch: false
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});